<template>
	<view class="page">
		<view class="hedaers">
			<div class="hedaersLeft">
				<div class="hedaersLeftH">{{$t('index.Welcome')}}!</div>
				<div class="hedaersLeftH">{{FormData.real_name || ''}}</div>
				<div class="hedaersLeftH">{{$t('index.dengji')}} {{dengji(FormData.level_id) || ''}}</div>

			</div>
			<div class="hedaersRight">
				<view class="hedaersRightItems">
					<image src="../../static/erweima.png" mode="" style="width: 75%;height: 75%;"
						@click="$next('/pages/home/MemberRegistration')"></image>
				</view>
				<view class="hedaersRightItems" @click="$next('/pages/home/PersonalData')">
					<image src="../../static/youjiantou.png" mode="" style="width: 55%;height: 55%;"></image>
				</view>
			</div>
		</view>
		<!-- 轮播图 -->
		<view class="lunbo">
			<u-swiper :list="lunBunDate" keyName="image" :current="current" :indicator="true" indicatorMode="dot"
				height="100%" radius="10rpx" style="width: 100%;"></u-swiper>
		</view>
		<!-- 尾部导航模块 -->
		<view class="foodter">
			<view class="foodterItems" v-for="(items,index) in foodterItemsData" :key="items.id"
				:class="[ index >= 0 ? 'marginTop' : '']" @click="goto(index)">
				<div class="foodterItemsTop">
					<image :src="items.icon" mode="" style="width: 55%;height: 55%;"></image>
				</div>
				<div class="foodterItemsB">
					{{items.text}}
				</div>
			</view>
		</view>
		<!-- <uploadApi></uploadApi> -->
	</view>
</template>

<script>
	import uploadApi from '../rt-uni-update.vue'
	// import getUpdate from '../../utils/mixin/upversion.js'
	export default {
		components: {
			uploadApi
		},
		// mixins:[getUpdate],
		data() {
			return {
				newUrl: 0, //0为新接口1为老接口
				FormData: {

				},
				// libraryRelease: false, //为false时没有登录验证去往library验证页面；为true时说明已经验证过了直接去往library列表页面
				current: 0,
				lunBunDate: [],
				foodterItemsData: [{
					icon: '../../static/qizi.png',
					text: this.$t('index.navItems1'),
					path: '/pages/home/Course'
				}, {
					icon: '../../static/sbgrcbxxdy.png',
					text: this.$t('index.navItems2'),
					path: '/pages/home/Licensing'
				}, {
					icon: '../../static/zhang.png',
					text: 'ATT',
					path: '/pages/home/att'
				}, {
					icon: '../../static/fort-awesome.png',
					text: this.$t('index.navItems4'),
					path: '/pages/home/Scoreboard'
				}, {
					icon: '../../static/blook.png',
					text: this.$t('index.navItems5'),
					path: '/pages/home/Library'
				}, {
					icon: '../../static/e.png',
					text: this.$t('index.navItems6'),
					path: '/pages/home/CompensationPlan'
				}],

				// {
				// 	icon: '../../static/taem.png',
				// 	text: this.$t('index.navItems7'),
				// 	path: '/pages/home/Team'
				// }, {
				// 	icon: '../../static/bob.png',
				// 	text: this.$t('index.navItems8'),
				// 	path: '/pages/News/News'
				// }, 
			}
		},
		onLoad() {
			this.FormData = {
				...JSON.parse(uni.getStorageSync('user'))
			}
		},
		onShow() {
			this.getLunBao()
		},
		methods: {
			// 等级划分
			dengji(val) {
				let txt = '';
				switch (val) {
					case 1:
						txt = 'TA';
						break;

					case 2:
						txt = 'MA';
						break;

					case 3:
						txt = 'FM';
						break;
					case 4:
						txt = 'MD';
						break;
					case 5:
						txt = 'FD';
						break;
					case 6:
						txt = 'RD';
						break;
					case 7:
						txt = 'ED';
						break;
					case 8:
						txt = 'EP';
						break;
				}
				return txt
			},
			// 获取首页轮播
			getLunBao() {
				uni.showLoading({
					title: this.$t('Laoding'),
				})
				this.$get('/biz/app/carouselImageList', {
					type: 2
				}, this.newUrl).then(res => {
					this.lunBunDate = res.data.data.map(items => {
						return {
							image: items.image,
						}
					})
				})
			},
			// 首页导航项的处理逻辑
			goto(index) {
				if (index == 7) {
					uni.switchTab({
						url: `${this.foodterItemsData[index].path}`
					})
				} else if (index == 4) {
					uni.showLoading({
						title: this.$t('Laoding'),
					})
					this.$post(`/biz/librarypwd/check`,{password:uni.getStorageSync('lgpad')} , 0).then(res => {
						if (res.message == "密码正确") {
							setTimeout(() => {
								uni.navigateTo({
									url: '/pages/home/Library'
								})
							}, 500)
						} else {
							setTimeout(() => {
								uni.navigateTo({
									url: `/pages/home/libraryCom/libraryProving`
								})
							}, 500)
						}
					})
					
					
					

				} else {
					uni.navigateTo({
						url: `${this.foodterItemsData[index].path}`
					})
				}
			}
		}
	}
</script>

<style>
	.page {
		overflow: hidden;
		width: 100%;
		height: 100vh;
		overflow-y: auto;
		padding: 0 30rpx;
		background-color: #F0F0F0;
		box-sizing: border-box;
	}

	.hedaers {
		position: relative;
		top: 0;
		right: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		height: 340rpx;
		border-radius: 10rpx;
		margin-top: 24rpx;
		background-color: #fff;
		padding: 0 35rpx;
		box-sizing: border-box;
		background-color: #fff;
		background-image: url('');
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}

	.hedaersLeft {
		height: 170rpx;
	}

	.hedaersLeftH:nth-child(1) {
		font-family: Montserrat;
		font-size: 16px;
		font-weight: 700;
		line-height: 28px;
		letter-spacing: 0.20000000298023224px;
		text-align: left;
		color: #273562;
	}

	.hedaersLeftH:nth-child(2) {
		font-family: Montserrat;
		font-size: 26px;
		font-weight: 700;
		line-height: 28px;
		letter-spacing: 0.20000000298023224px;
		text-align: left;
		margin: 10rpx 0 10rpx;

	}

	.hedaersLeftH:nth-child(3) {
		font-family: Montserrat;
		font-size: 16px;
		font-weight: 700;
		line-height: 28px;
		letter-spacing: 0.20000000298023224px;
		text-align: left;
		color: #273562;
	}

	.hedaersRight {
		display: flex;
		align-items: flex-start;
		justify-content: flex-end;
		height: 170rpx;
	}

	.hedaersRightItems {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
		background-color: #273562;
	}

	.hedaersRightItems:last-child {
		margin-left: 28rpx;
	}

	.lunbo {
		width: 100%;
		height: 300rpx;
		/* background-color: cadetblue; */
		margin-top: 36rpx;
	}

	.foodter {
		display: flex;
		align-content: center;
		justify-content: space-between;
		flex-wrap: wrap;
		width: 100%;
		height: 500rpx;
		background-color: #fff;
		margin-top: 36rpx;
		border-radius: 10rpx;
		padding: 0 28rpx;
		box-sizing: border-box;
	}

	.foodterItems {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
		/* width: 160rpx; */
		flex: 0 0 33.33333%;
		/* 每个元素占据行宽的三分之一 */
		box-sizing: border-box;
		/* 防止边框和内边距破坏布局 */
		height: 166rpx;
		/* background-color: coral; */
	}

	.foodterItemsTop {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 110rpx;
		height: 110rpx;
		background-color: #273562;
		border-radius: 50%;
	}

	.foodterItemsB {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 56rpx;
		font-family: Montserrat;
		font-size: 10px;
		font-weight: 400;
		/* line-height: 56rpx; */
		letter-spacing: 0.20000000298023224px;
		text-align: center;
		white-space: normal;
		word-wrap: break-word;
		overflow-wrap: break-word;

	}

	.marginTop {
		margin-top: 16rpx;
	}
</style>